package com.kinoshita.flow.controller.api;

import com.kinoshita.common.result.ResultDO;
import com.kinoshita.flow.api.domain.LoanInitDO;
import com.kinoshita.flow.api.domain.LoanTaskDO;
import com.kinoshita.flow.api.query.TaskQueryDO;
import com.kinoshita.flow.service.ILoanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/loan-api")
public class LoanAPI {

    @Autowired
    private ILoanService loanService;

    @PostMapping("/startFlow")
    public @ResponseBody ResultDO startFlow(@RequestBody LoanInitDO domain) {
        return loanService.startFlow(domain);
    }

    @PostMapping("/getUserTask")
    public @ResponseBody ResultDO getUserTask(@RequestBody TaskQueryDO queryDO) {
        return loanService.queryTaskByUsername(queryDO);
    }

    @PostMapping("/apply")
    public @ResponseBody ResultDO apply(@RequestBody LoanTaskDO domain) {
        return loanService.apply(domain);
    }

    @PostMapping("/approval")
    public @ResponseBody ResultDO approval(@RequestBody LoanTaskDO domain) {
        return loanService.approval(domain);
    }

}
